2010カスタムリボンにアクセス (access 2010 custom ribbon)


問題の説明

2010カスタムリボンにアクセス (access 2010 custom ribbon)

I have a custom ribbon that calls vba commands. When it does, I get the error message

Microsoft Access cannot run the macro or callback function [FUNCTION OR SUB]

where [FUNCTION OR SUB] is the Function or Sub name I am calling.

An example of the code that generates the above message is:

Public Function OnButtonPress2(ctl As IRibbonControl)

    MsgBox "OnButtonPress2"

End Function

Where OnButtonPress2 is called in the ribbon's XML file for a button as

onAction="OnButtonPress2

The above works for a macro, so it's likely not to be the ribbon's xml

======== VERSION 2 I've created a new simple test db with the XML and module shown below:

The results of each are:

Macro1 ‑ works fine (it has a popup message)

CommandOnAction2 ‑ msgbox "There was an error compiling this function"

OnButtonPress2 ‑ msgbox  "Microsoft Access cannot run the macro or callback function 'OnButtonPress2 '

on the line "Public gobjRibn As IRibbonUI", IRibbonUI does not autocomplete leading me to believe there is a reference that needs to be added

XML (Ribbon name is NewRibbon and is set to open on startup)

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="tab1" label="Your Custom Tab">

<group id="group1" label="Your Custom Group">
<button id="SampleButton" label="Macro1" onAction="Macro1" />
<button id="SampleButton2" label="CommandOnAction2" onAction="=CommandOnAction2()"  />
<button id="SampleButton3" label="OnButtonPress2" onAction="OnButtonPress2"  />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

module (name is modRibbon)

Option Compare Database

Public gobjRibn As IRibbonUI

Public Function CommandOnAction2(ByVal ctl As IRibbonControl)
    MsgBox "Function CommandOnAction2"
End Function

Public Sub OnButtonPress2(ByVal ctl As IRibbonControl)
    MsgBox " Sub OnButtonPress2"
End Sub

リファレンスソリューション

方法 1:

I was able to recreate your issue in Access 2010 and I got your example to work by changing the Function to a Sub that looks like this:

Public Sub OnButtonPress2(ByVal control_ As IRibbonControl)
    MsgBox "OnButtonPress2"
End Sub

BTW, while searching for information on this issue I stumbled upon a posting in another forum here. In it, Albert D. Kallal discusses using onAction="=MyPublicFunctionName()" as an alternative to callbacks; perhaps you may find that useful in some cases.

(by user1737050Gord Thompson)

リファレンスドキュメント

  1. access 2010 custom ribbon (CC BY‑SA 3.0/4.0)

#vba #ribbon #ms-access






関連する質問

2010カスタムリボンにアクセス (access 2010 custom ribbon)

セルに値が保存されているファイルを開く (Open files with values stored in cells)

コンソールはプログラミング言語で制御できますか? (Can consoles be controlled by programming languages?)

このコードを変更して、最後の行の下の行にデータを貼り付けるにはどうすればよいですか? (How do I modify this code to paste in the row under last row with data?)

Selenium-vba クラス名で要素を取得 (Selenium-vba Get element by Class Name)

セルからデータを抽出し、セルをアルファベット順に並べ替えるにはどうすればよいですか? (How do I extract data from a cell and order the cells alphabetically?)

VBAコードがセルをアクティブにしない (VBA code not activating cell)

列をExcel VBAループして、空白以外をコピーして他の3つの列に貼り付けますか? (Excel VBA Loop through Column to Copy and Paste Non Blanks to 3 other Columns?)

コードは 2 つの製品で動作しますが、3 番目の製品コードを追加すると、データが取得されますが、3 番目の製品だけに保存されません。どうしたの? (Code works with two products but when I add a third product code grabs data but doesn't save it only for third product. What's wrong with it?)

シート 2 の範囲内のセル名に基づいてシート (シート 1) を複製して名前を変更するために必要な VBA コード (VBA code needed to duplicate and rename a sheet (Sheet 1) based on cell names in a range on Sheet 2)

signtool.exe エラー: Excel マクロの署名時に SignerSign() が失敗しました (-2147220492/0x800403f4) (signtool.exe Error: SignerSign() failed (-2147220492/0x800403f4) when signing Excel Macro)

Excelで1つの列の「 - 」で区切られたデータを複数に分割する (Divide data separated from ' - ' in one column into more in excel)







コメント